package com.sun.pm.test;

import oracle.jdbc.OracleTypes;
import org.junit.Test;

import java.sql.*;

public class OracleDemo {

    @Test
    public void test1() throws Exception{
        //数据库驱动
        Class.forName("oracle.jdbc.driver.OracleDriver");
        //连接对象
        Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@192.168.83.10:1521:orcl", "itheima", "itheima");
        //预处理的statement对象
        PreparedStatement pst = connection.prepareStatement("select * from emp where empno = ?");
        //赋值
        pst.setInt(1,7788);
        //执行sql
        ResultSet rs = pst.executeQuery();

        while (rs.next()){
            System.out.println(rs.getString("ename"));
        }
        rs.close();
        pst.close();
        connection.close();
    }


    @Test
    public void test2() throws Exception{
        //数据库驱动
        Class.forName("oracle.jdbc.driver.OracleDriver");
        //连接对象
        Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@192.168.83.10:1521:orcl", "itheima", "itheima");
        //预编译的statement对象
//        PreparedStatement pst = connection.prepareStatement("select * from emp where empno = ?");
        CallableStatement callableStatement = connection.prepareCall("{call p_yearsal(?,?)}");
        //赋值
        callableStatement.setInt(1,7788);
        callableStatement.registerOutParameter(2, OracleTypes.NUMBER);
        //执行sql
        callableStatement.execute();

        //输出结果
        System.out.println(callableStatement.getObject(2));
        callableStatement.close();
        connection.close();
    }
	
	 @Test
    public void test2() throws Exception{
        //数据库驱动
        
    }
	 @Test
    public void test_a() throws Exception{
        //数据库驱动
        
    }
	
	 @Test
    public void test_b() throws Exception{
        //数据库驱动
        
    }
	 @Test
    public void branch_a() throws Exception{
        //数据库驱动
        
    }
	 @Test
    public void branch_b() throws Exception{
        //数据库驱动
        
    }
	 @Test
    public void branch_a() throws Exception{
        //数据库驱动
        
    }
	 @Test
    public void test_master() throws Exception{
        //数据库驱动
        
    }
	
	
}
